﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;

namespace Tencent.OA.App
{
    /// <summary>
    /// 日志配置节点
    /// </summary>
    public class LoggerSection : ConfigurationSection
    {
        public const string LoggerSectionKey = "logger";
        /// <summary>
        /// 日志级别
        /// </summary>
        [ConfigurationProperty("level", IsRequired = true)]
        public LogLevel Level
        {
            get
            {
                if (string.IsNullOrEmpty(base["level"].ToString()))
                    throw new Exception("logger节点的level值不能为空。");
                return (LogLevel)base["level"];
            }
        }
        /// <summary>
        /// 日志文件路径
        /// </summary>
        [ConfigurationProperty("logFilePath", IsRequired = true, DefaultValue = "EventLog\\")]
        public string LogFilePath
        {
            get
            {
                if (string.IsNullOrEmpty((string)base["logFilePath"]))
                    throw new Exception("logger节点的logFilePath值不能为空。");
                return (string)base["logFilePath"];
            }
        }

        /// <summary>
        /// 日志文件路径
        /// </summary>
        [ConfigurationProperty("logFileFormat", DefaultValue = "yyyy-MM-dd&quot;-eventLogger.log&quot;")]
        public string LogFileFormat
        {
            get
            {
                if (string.IsNullOrEmpty((string)base["logFileFormat"]))
                    throw new Exception("logger节点的logFileFormat值不能为空。");
                return (string)base["logFileFormat"];
            }
        }
    }
}
